package service

import (
	ClickHouse "gin/database"
	"gin/model"
)

type Tenant struct {
}

type WorkBase struct {
	City     string    `json:"city"`
	Val      []float64 `json:"val"`
	Type     uint64    `json:"type"`
	IsCenter bool      `json:"isCenter"`
}

type GetWorkBaseRes struct {
	List []WorkBase `json:"list"`
}

// GetWorkBase 获取租户办公地点
func (t Tenant) GetWorkBase(tenantId uint64) (res GetWorkBaseRes, err error) {
	res.List = []WorkBase{
		{
			City:     "长沙",
			Val:      []float64{112.98626, 28.25591},
			Type:     0,
			IsCenter: true,
		},
		{
			City:     "北京",
			Val:      []float64{116.23128, 40.22077},
			Type:     0,
			IsCenter: false,
		},
		{
			City:     "成都",
			Val:      []float64{104.085968, 30.64911},
			Type:     0,
			IsCenter: false,
		},
		{
			City:     "深圳",
			Val:      []float64{114.102496, 22.603986},
			Type:     0,
			IsCenter: false,
		},
		{
			City:     "上海",
			Val:      []float64{121.397752, 31.239881},
			Type:     0,
			IsCenter: false,
		},
	}
	return
}

// GetList 查询租户列表
func (t *Tenant) GetList(where interface{}) (res []model.Tenant, err error) {
	query := ClickHouse.DB.Model(&model.Tenant{})
	if where != nil {
		query.Where(where)
	}
	err = query.Find(&res).Error
	return
}
